package site.kexing.controller;

import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import site.kexing.mapper.Product_OrderMapper;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class IndexController {
    @Autowired
    private Product_OrderMapper product_orderMapper;
    @RequestMapping("/index")
    public String toIndex(){
        return "index";
    }

    @RequestMapping("/product")
    public String toProduct(){
        return "product";
    }

    @RequestMapping("/productupdate")
    public String toProductUpdate(){
        return "productUpdate";
    }

    @RequestMapping("/productinsert")
    public String toProductInsert(){
        return "productInsert";
    }

    @RequestMapping("equipment")
    public String toEquipment(){
        return "equipment";
    }

    @RequestMapping("/equipmentinsert")
    public String toEquipmentInsert(){
        return "equipmentInsert";
    }

    @RequestMapping("/login")
    public String toLogin(){
        return "login";
    }

    @RequestMapping("register")
    public String toRegister(){
        return "register";
    }

    @ResponseBody
    @RequestMapping("/selectinfo")
    public String selectInfo(){
        int num1 = product_orderMapper.selectPro1();
        int num2 = product_orderMapper.selectPro2();
        int num3 = product_orderMapper.selectPro3();
        int num4 = product_orderMapper.selectPro4();
        int num5 = product_orderMapper.selectPro5();
        Map<String,Integer> nums = new HashMap<>();
        nums.put("num1",num1);
        nums.put("num2",num2);
        nums.put("num3",num3);
        nums.put("num4",num4);
        nums.put("num5",num5);
        String s = JSON.toJSONString(nums);
        return s;
    }

}
